<template>
  <div class="app-container" style="display:flex;">
    <div style="width: 100%;">
      <div class="filter-container">
        <el-form ref="dataForm" v size="mini" :model="listQuery" label-position="right" label-width="auto">
          <div class="lineBox">
            <el-tabs v-model="activeName" @tab-click="handleClick">
              <el-tab-pane label="英文别名去除" name="1" />
              <el-tab-pane label="人物实体类型校正" name="2" />
            </el-tabs>
          </div>
        </el-form>
      </div>

      <div class="myTable1">
        <div style="min-height:650px; width: 100%; padding: 20px 40px 40px 20px;">
          <div>
            <div style="margin-bottom: 20px;color: rgb(204, 204, 204);">
              大模型抽取过程中可能生成一些英文别名，执行以下图数据库语句将其清理。
            </div>

            <div style="margin-bottom: 20px;">
              <el-input v-model="textarea" type="textarea" :autosize="{ minRows: 4, maxRows: 4}" placeholder=""
                style="width: 500px;" :disabled="true" />
            </div>

            <div>
              <el-button type="primary" :loading="loading" @click="onSubmit">
                执行
              </el-button>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { artApi } from '@/api/art'

export default {

  data() {
    return {
      loading: false,
      activeName: "1",
      textarea: `MATCH (n) WHERE n.name IS NOT NULL AND n.name =~ '^(?=.*[A-Za-z])[A-Za-z0-9\\s\\-]+$' DETACH DELETE n;`,

      selectedNode: null,
      listLoading: false,
      listQuery: { name: "" },


    }
  },



  mounted() {

  },
  methods: {

    handleClick(tab, event) {
      console.log(this.activeName);

      if (this.activeName == 1) {
        this.textarea = `MATCH (n) WHERE n.name IS NOT NULL AND n.name =~ '^(?=.*[A-Za-z])[A-Za-z0-9\\s\\-]+$' DETACH DELETE n;`
      } else {
        this.textarea = 'MATCH (other:`db.Others`) OPTIONAL MATCH(person: `db.Person` { name: other.name }) WITH other, person WHERE person IS NOT NULL CALL apoc.refactor.mergeNodes([person, other], { properties: "combine", mergeRels: true }) YIELD node RETURN node;';
      }


    },

    async onSubmit() {


      this.loading = true
      const params = {
        type: this.activeName,
      }

      let data = localStorage.getItem('data');
      let arr = JSON.parse(data)
      params.project_id = arr.id


      const response = await artApi("manipulation", params)

      if (response.code == 200) {

        this.$message.success(response.message)
      }
      this.loading = false

    },

  }
}
</script>

<style lang="scss" scoped>
.always-underlined {
  text-decoration: underline;
}
.custom-font {
  color: rgba(0, 0, 0, 0.85);
  font-size: 12px;
  line-height: 1.5715;
  word-break: break-word;
  overflow-wrap: break-word;
  font-weight: normal !important;
}

::v-deep .el-card.is-always-shadow {
  min-height: 60px;
}
::v-deep .el-card__body {
  padding: 10px;
}
::v-deep .el-table__empty-text {
  font-weight: normal !important;
  font-size: 12px;
}

::v-deep .el-table__row {
  height: 30px; /* 设置你想要的行高 */

  td {
    padding: 5px 0;
  }
}

html,
body,
.app-container {
  height: 100%; /* 设置 html 和 body 以及 .app-container 的高度为 100% */
  margin: 0; /* 清除默认边距 */
}

.dhtitle {
  margin-top: 5px;
  color: #6ea3fd;
}

.myTable1 {
  background-color: #fff;
  // padding: 40px 20px 0px 20px;
}
.demo-image__preview {
  float: left;
  margin-left: 5px;
}
.demonstration {
  font-size: 12px;
  color: #333;
  font-weight: normal;
}
.bixi-group-container-title {
  color: #363b45;
  font-size: 12px;
  font-weight: 550;
  margin: -4px 0;
  margin-top: 2px;
}
.bixi-group-container-blue-block {
  background: #4d67be;
  border-radius: 0 4px 4px 0;
  display: inline-block;
  height: 12px;
  margin-right: 4px;
  position: relative;
  top: 1px;
  width: 3px;
}

.groupcontainer-title-F4sp83QczG {
  font-size: 12px;
  font-weight: 600;
}

.bixi-group-container-description {
  color: #b9bbbe;
  font-size: 12px;
  font-weight: 400;
  line-height: 30px;
  margin-left: 8px;
}

.ellipsis-multiline {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1; /* 设置最大显示行数 */
  overflow: hidden;
  text-overflow: ellipsis;
  // width: 200px;
  // border: 1px solid #ccc;
  // padding: 5px;
}
.badge-container {
  cursor: pointer;
  margin-left: 10px;
  margin-bottom: 10px;
  display: inline-flex;
  align-items: center;
  background-color: #e8f4ff;
  border-color: #d1e9ff;
  border-radius: 5px;
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.1);
  padding: 5px 10px;
  font-family: "Arial", sans-serif;
  font-size: 12px;
  color: #1890ff;
}

.badge-left {
  margin-right: 10px;
  color: #1890ff;
}

.badge-right {
  background-color: #2bd6d6;
  border-radius: 10px;
  padding: 0px 10px;
  color: #333;
  // box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15),
  //   /* 外部阴影 */ inset 0 -3px 5px rgba(255, 255, 255, 0.7);
  /* 内部上阴影 */

  /* 添加过渡效果 */
}
</style>
